#/bin/bash
Cur_day=`date -d '1 day ago' +%Y%m%d`
TIME_WAIT_MAX=36000
TIME_SLEEP=300
#运行时传城市参数进来 $1
bj_today=$1"_$Cur_day"
Local_inputdata_path=/usr/local/apps/hadoop/data
Local_code_path=/usr/local/apps/hadoop/rent
Local_hadoop_path=/usr/local/apps/hadoop-2.7.2/share/hadoop/tools/lib
#删除文件，如果存在的话
if [ -f /usr/local/apps/hadoop/data/house_rent_gov.gz ]
      then
      rm -rf /usr/local/apps/hadoop/data/house_rent_gov.gz
fi
#运行时传该城市对应的数据库名作为第二个参数
python /usr/local/apps/hadoop/rent/dumpdata.py $2
#compress the data, format=gzip
gzip $Local_inputdata_path/house_rent_gov
hadoop fs -mkdir /house_rent/$bj_today
hadoop fs -copyFromLocal $Local_inputdata_path/house_rent_gov.gz /house_rent/$bj_today/house_rent_gov.gz
mkdir $Local_inputdata_path/rent/$bj_today/
mkdir $Local_inputdata_path/rent/$bj_today/house_rent
mkdir $Local_inputdata_path/rent/$bj_today/house_rent_gov
mkdir $Local_inputdata_path/rent/$bj_today/house_rent_pic
